// pages/message_list/message_list.js
const app = getApp(), core = require('../../utils/core'), util = require('../../utils/util');
Page({

  /**
   * 页面的初始数据
   */
  data: {},

  onLoad(options) {
    switch (options.type) {
      case 'personal':
        this.data.url = 'xilujob.message/personal_list';
        this.data.listField = 'personal_messages';
        wx.setNavigationBarTitle({title: '通知消息'});
        break;
      case 'activity':
        this.data.url = 'xilujob.message/activity_list';
        this.data.listField = 'activity_messages';
        wx.setNavigationBarTitle({title: '活动消息'});
        break;
      case 'system':
        this.data.url = 'xilujob.message/system_list';
        this.data.listField = 'system_messages';
        wx.setNavigationBarTitle({title: '系统消息'});
        break;
      default:
        wx.navigateBack();
        return;
    }
    this.fetch();
  },
  fetch() {
    util.fetch(this, this.data.url, {}, 'listMore', 'list', this.data.listField);
  },

  goRedirect(event) {
    let index = event.currentTarget.dataset.index;
    let message = this.data.list[index];
    return false;
    switch(message.type) {
      case 2://简历被查看
        wx.navigateTo({url: '/pages/look_my/look_my'});
        break;
      case 1://简历投递，通知企业用户
        wx.navigateTo({url:'/pages/application_management/application_management'});
        break;
      case 4://面试邀请
        wx.navigateTo({url:'pages/interview_invitation/interview_invitation'});
        break;
      case 5://面试邀请被用户拒绝
        wx.navigateTo({url:'pages/invitation/invitation'});
        break;
      case 6://面试邀请被用户同意
        wx.navigateTo({url:'pages/invitation/invitation'});
        break;
      case 7://面试失败
        wx.navigateTo({url:'pages/interview_invitation/interview_invitation'});
        break;
      case 8://面试通过
        wx.navigateTo({url:'pages/interview_invitation/interview_invitation'});
        break;
    }
  }

});
